/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bit.entidade;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author marcelo
 */
@Entity
@Table(name = "servico")
@NamedQueries({@NamedQuery(name = "Servico.findAll", query = "SELECT s FROM Servico s"), @NamedQuery(name = "Servico.findById", query = "SELECT s FROM Servico s WHERE s.id = :id"), @NamedQuery(name = "Servico.findByNome", query = "SELECT s FROM Servico s WHERE s.nome = :nome"), @NamedQuery(name = "Servico.findByPorta", query = "SELECT s FROM Servico s WHERE s.porta = :porta")})
public class Servico implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Basic(optional = false)
    @Column(name = "nome")
    private String nome;
    @Column(name = "porta")
    private Integer porta;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idServico")
    private Collection<MaquinaServico> maquinaServicoCollection;

    public Servico() {
    }

    public Servico(Long id) {
        this.id = id;
    }

    public Servico(Long id, String nome) {
        this.id = id;
        this.nome = nome;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public Integer getPorta() {
        return porta;
    }

    public void setPorta(Integer porta) {
        this.porta = porta;
    }

    public Collection<MaquinaServico> getMaquinaServicoCollection() {
        return maquinaServicoCollection;
    }

    public void setMaquinaServicoCollection(Collection<MaquinaServico> maquinaServicoCollection) {
        this.maquinaServicoCollection = maquinaServicoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Servico)) {
            return false;
        }
        Servico other = (Servico) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "bit.entidade.Servico[id=" + id + "]";
    }

}
